1. Field of the Invention
This invention relates generally to computer software and, more particularly, to a method for providing variable sized data members.
2. Description of the Related Art
There is a constant drive within the computer industry to decrease wasted space in data storage and to increase the speed, ease and convenience of adding, editing and/or deleting stored data. Programming languages typically provide the facility of storing data into storage areas called “variable,” for example. Depending on the programming language specifications, variables are of different types and sizes. For example, in the C programming language, the variable type “int” (for integer type) can store a 32-bit signed integer quantity int i=±b31b30b29 . . . b3b2b1, where b31 is the most significant bit, b1 is the least significant bit and ± is the sign bit.
Most programming languages also allow the programmer to define new data types (variables) by combining together existing types. For example, a variable type “Bank_Account” can have the following data types (using the C programming language structures):
struct Bank_Account {intaccount_no;intbalance;characcount_type;charmember_name[100];};where the last member of the data structure “member_name” defines the member name to be an array of 100 characters or bytes (8 bits). This means that there are a maximum of 100 bytes reserved for storing the name of the member. If the actual name of the member is longer than 100 bytes long, the actual name will be truncated down to only 100 bytes (typically the first 100 bytes in the member name reading from right to left). Also, as shown in FIG. 1, if the actual member name 100, such as “Jane Doe,” is less than 100 bytes, only the first 8 bytes will be used and the remaining 92 bytes will not be used.
All data types in a programming language have a fixed size, not only the basic ones like “int,” “char” and the like, but also the ones that are built by combining the basic types, as in the “Bank_Account” example described above. There are conventionally two ways to store the member name. The first conventional way is to estimate the maximum space required to store the biggest member name and then allocate that maximum amount of space as a part of the data structure, as in the member name 100 shown in FIG. 1. However, this approach typically wastes too much storage space because most actual member names will not be more than about 20 characters or bytes long, yet the programmer is allocating 100 bytes of storage space for all the member names uniformly.
The second conventional way is not to allocate space for storing a member name in the data structure at all, but rather to allocate this storage space somewhere else. For example, as shown in FIG. 2, the member name “Jane Doe” is not stored in a data structure storage with cross-reference to member name storage 200, but rather in a separate member name storage 220 different from the data structure storage with cross-reference to member name storage 200. Only as much storage space as needed may be allocated in the member name storage 220. However, this approach typically is very complicated to handle. Consider storing such a record into a disk file. If the member name is not part of the data structure, the member name not only must be stored in a separate storage location, but must also be stored in such way that adding, editing and/or deleting the data structure, including the member name, is fast and easy. However, this is very difficult to achieve if the member name is not part of the data structure and the member name is stored in a separate storage location.
The present invention is directed to overcoming, or at least reducing the effects of, one or more of the problems set forth above.